import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

// 继承是为了复用之前的代码
public class UdpDicServer extends UDPServer{
    private Map<String,String> map = new HashMap<>();

    public UdpDicServer(int port) throws SocketException {
        super(port);
        map.put("dog","小狗");
        map.put("fuck","握草");
        map.put("cute","可爱");
        map.put("cat","小猫");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,
                "查无此单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDicServer udpDicServer = new UdpDicServer(9090);
        udpDicServer.start();
    }
}
